home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / patches / thinkc.sit / Think ƒ / unixatof.c < prev    next >
Text File  |  1989-02-25  |  996b  |  60 lines

  1. /*    (C) Copyright 1986. THINK Technologies, Inc.  All rights reserved. */    
  2.  
  3. #include "unix.h"
  4. #include "sane.h"
  5. #include "MacTypes.h"
  6.  
  7. #ifndef _math_
  8. #include "Math.h"
  9. #endif
  10.  
  11. #ifdef _MC68881_
  12.  
  13. #define _toDecimal() fp68k(&_decimal_,&x80,FFEXT|FOD2B)
  14. #define _tox96() x80tox96(&x80, &x)
  15.  
  16. /* conversion from 68881 to SANE extended type */
  17. static void x96tox80(x96, x80)
  18. register Extended96 *x96;
  19. register Extended80 *x80;
  20.  
  21. {
  22.     (*x80).exponent = (*x96).exponent;
  23.     (*x80).mantissa = (*x96).mantissa;
  24. }
  25.  
  26. static void x80tox96(x80, x96)
  27. register Extended80 *x80;
  28. register Extended96 *x96;
  29. {
  30.     (*x96).exponent = (*x80).exponent;
  31.     (*x96).reserved = 0;
  32.     (*x96).mantissa = (*x80).mantissa;
  33. }
  34.  
  35. #else
  36.  
  37. #define _toDecimal() fp68k(&_decimal_,&x,FFEXT|FOD2B)
  38. #define _tox96()
  39.  
  40. #endif
  41.  
  42. double atof(s)
  43. char *s;
  44.  
  45. {
  46.  
  47.     Decimal    _decimal_;
  48.     int        index=0;
  49.     Boolean     read_error;
  50.     double    x;
  51.     
  52.     #ifdef _MC68881_
  53.     Extended80 x80;
  54.     #endif
  55.     
  56.         CStr2Dec(s,&index,&_decimal_,&read_error);
  57.         _toDecimal();
  58.         _tox96();
  59.         return(x);
  60. }